from itertools import count


class AttrDisplay:
    def gatherAttrs(self):
        attrs = []
        for key in sorted(self.__dict__):
            attrs.append('%s = %s' % (key, getattr(self, key)))
        return ', '.join(attrs)

    def __repr__(self) -> str:
        return '[%s : %s]' % (self.__class__.__name__, self.gatherAttrs())

if __name__ == '__main__':
    class TopTest(AttrDisplay):
        count = 0
        def __init__(self) -> None:
            self.attr1 = TopTest.count
            self.attr2 = TopTest.count + 1
            TopTest.count += 2 
    class SubTest(TopTest): 
        def __init__(self) -> None:
            TopTest.__init__(self)
            self.sub = 'sub'

    X,Y = TopTest(),SubTest()
    print(X)
    print(Y)

